using System;

namespace OracleInternal.Sharding
{
	internal class RoutingKey : IEquatable<RoutingKey>
	{
		private int hashCode;

		internal SuperShardingKeys SuperShardingKeys
		{
			get;
			set;
		}

		internal ShardingKeys ShardingKeys
		{
			get;
			set;
		}

		internal RoutingKey(ShardingKeys keys, SuperShardingKeys superShardingKeys)
		{
			SuperShardingKeys = superShardingKeys;
			ShardingKeys = keys;
			int num = 1;
			num = 31 * num + (superShardingKeys?.GetHashCode() ?? 0);
			num = (hashCode = 31 * num + (keys?.GetHashCode() ?? 0));
		}

		public override int GetHashCode()
		{
			return hashCode;
		}

		public override bool Equals(object obj)
		{
			RoutingKey routingKey = obj as RoutingKey;
			if (routingKey == null)
			{
				return false;
			}
			return Equals(routingKey);
		}

		public bool Equals(RoutingKey other)
		{
			if (other == null)
			{
				return false;
			}
			if (SuperShardingKeys.Equals(SuperShardingKeys, other.SuperShardingKeys) && ShardingKeys.Equals(ShardingKeys, other.ShardingKeys))
			{
				return true;
			}
			return false;
		}

		public override string ToString()
		{
			string arg = ((ShardingKeys == null) ? "[]" : ShardingKeys.ToString());
			string arg2 = ((SuperShardingKeys == null) ? "[]" : SuperShardingKeys.ToString());
			return $"Sharding Key = {arg}, Super Sharding Key = {arg2}";
		}
	}
}
